﻿using UnityEngine;
using UnityEngine.UI;

namespace Example_1000_UGUICode_02
{
	public class UIMain : MonoBehaviour {

		void Start () 
		{
			CreatImage(loadSprite("L pose-2"));
			CreatImage(loadSprite("L pose-1"));
		}
	
		private void CreatImage(Sprite sprite ){
			GameObject go = new GameObject(sprite.name);
			go.layer = LayerMask.NameToLayer("UI");
			go.transform.parent = transform;
			go.transform.localScale= Vector3.one;
			Image image = go.AddComponent<Image>();
			image.sprite = sprite;
			image.SetNativeSize();
		}
	
		private Sprite loadSprite(string spriteName){
			return Resources.Load<GameObject>("Example_0000_Atlas_01/" + spriteName).GetComponent<SpriteRenderer>().sprite;
		}
	}
}

